const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
    mode: 'development',
    // entry: './src/main.js',//单入口
    entry: {//多入口
      'js/main': './src/main.js',
      'js/login': './src/js/login.js'
    },
    output: {
        path: path.join(__dirname,'../dist'),
        filename: '[name].[chunkhash:8].js',
        // filename: '[name].js'
        clean: true
    },
    module: {
        rules: [
          {
            test: /\.css$/i,
            use: ['style-loader', 'css-loader']
          },
          {
            test: /\.scss$/i,
            use: ['style-loader', 'css-loader','sass-loader']
          }
        ]
    },
    plugins: [//插件
      new HtmlWebpackPlugin({
        template: path.join(__dirname,'../public/index.html'),
        filename: 'index.html',
        chunks: ['js/main']
      }),
      new HtmlWebpackPlugin({
        template: path.join(__dirname,'../public/html/login.html'),
        filename: 'html/login.html',
        chunks: ['js/login']
      })
    ],
    resolve: {
      alias: {
        '@': path.join(__dirname,'../src')
      }
    },
    devServer: { //webpack-dev-serve配置
      port:3000,
      open: true,
      proxy: {

      }
    }
}